<template>
    <van-nav-bar title="搜索结果" left-text="返回" left-arrow @click-left="$router.back()" fixed placeholder />
    <van-row :gutter="[20, 20]">
        <van-col span="12" v-for="(item) in listArr" :key="item.proid" @click="onDetail(item.proid)">
            <van-card :price="item.originprice" :desc="item.desc" :title="item.proname" :thumb="item.img1" />
        </van-col>
    </van-row>
</template>

<script setup>
import { ref } from 'vue';
// import axios from 'axios';
import { useRoute } from 'vue-router';
import { useRouter } from 'vue-router';
import { searchListReq } from '@/api/home';

let router = useRouter();
let route = useRoute();
let listArr = ref([]);
getData();
async function getData() {
    // let r = await axios.get("http://localhost:3001/api/pro/search", { params: { keyword: route.query.keyword } });
    searchListReq(route.query.keyword).then((r) => {
        listArr.value = r.data.data;
    })

}
// 点击跳转详情页面
function onDetail(id) {
    // console.log(id);
    router.push('/detail?proid=' + id);
}
</script>

<style></style>